//
//  toolClass.m
//  IlPhoto
//
//  Created by 준기 반 on 11. 6. 5..
//  Copyright 2011 한성대학교. All rights reserved.
//

#import "toolClass.h"
#import "iPhoneFilter.h"


@implementation toolClass

CGContextRef CreateRGBABitmapContext(CGImageRef inImage){
    CGContextRef    context = NULL;
    CGColorSpaceRef colorSpace;
    void *          bitmapData;
    int             bitmapByteCount;
    int             bitmapBytesPerRow;
	
	// Get image width, height. We'll use the entire image.
    size_t pixelsWide = CGImageGetWidth(inImage);
    size_t pixelsHigh = CGImageGetHeight(inImage);
	//int bitPerPixel = CGImageGetBitsPerPixel(inImage);
	//int bitPerComponent = CGImageGetBitsPerComponent(inImage);
    // Declare the number of bytes per row. Each pixel in the bitmap in this
    // example is represented by 4 bytes; 8 bits each of red, green, blue, and
    // alpha.
    bitmapBytesPerRow   = (pixelsWide * 4);
    bitmapByteCount     = (bitmapBytesPerRow * pixelsHigh);
	
    // Use the generic RGB color space.
	//colorSpace = CGImageGetColorSpace(inImage);
    //colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	colorSpace = CGColorSpaceCreateDeviceRGB ();
	
    if (colorSpace == NULL)
    {
        fprintf(stderr, "Error allocating color space\n");
        return NULL;
    }
	
    // Allocate memory for image data. This is the destination in memory
    // where any drawing to the bitmap context will be rendered.
    bitmapData = malloc( bitmapByteCount );
	
	if (bitmapData == NULL) 
    {
        fprintf (stderr, "Memory not allocated!");
        CGColorSpaceRelease( colorSpace );
        return NULL;
    }
	
    // Create the bitmap context. We want pre-multiplied ARGB, 8-bits 
    // per component. Regardless of what the source image format is 
    // (CMYK, Grayscale, and so on) it will be converted over to the format
    // specified here by CGBitmapContextCreate.
	
    context = CGBitmapContextCreate (bitmapData,
									 pixelsWide,
									 pixelsHigh,
									 8,      // bits per component
									 bitmapBytesPerRow,
									 colorSpace,
									 kCGImageAlphaPremultipliedLast);
    if (context == NULL)
    {
        free (bitmapData);
        fprintf (stderr, "Context not created!");
    }
	
    // Make sure and release colorspace before returning
    CGColorSpaceRelease( colorSpace );
	
    return context;
}

+(unsigned char*) CGImageToRawdata:(CGImageRef) inImage{
	
	
	
	// Create the bitmap context
	CGContextRef cgctx =CreateRGBABitmapContext(inImage);
	if (cgctx == NULL) 
	{ 
		// error creating context
		return NULL;
	}
	
	// Get image width, height. We'll use the entire image.
	size_t w = CGImageGetWidth(inImage);
	size_t h = CGImageGetHeight(inImage);
	CGRect rect = {{0,0},{w,h}}; 
	
	// Draw the image to the bitmap context. Once we draw, the memory 
	// allocated for the context for rendering will then contain the 
	// raw image data in the specified color space.
	CGContextDrawImage(cgctx, rect, inImage); 
	
	// Now we can get a pointer to the image data associated with the bitmap
	// context.
	void *data = CGBitmapContextGetData (cgctx);
	CGContextRelease( cgctx );
	
	
	if (data != NULL)
	{
		
		
	}
	
	// When finished, release the context
	//CGContextRelease(cgctx); 
	// Free image data memory for the context
	if (data)
	{
		//       free(data);
	}
	return data;
	
	
	
}

+(UIImage*)imageFilter2:(UIImage *)image{  //밝아짐.
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	//(<#unsigned char *pSrc#>, <#unsigned int width#>, <#unsigned int height#>)
	iPhonePhotoBiningFilter2(pSrc, image.size.width, image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	return returnIMG;
}
+(UIImage*)imageFilter3:(UIImage*)image{   //괜찮음
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhoto16bitColor(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}


+(UIImage*)imageFilter1:(UIImage *)image{
	switch (image.imageOrientation){
		case UIImageOrientationUp:
			NSLog(@"UIImageOrientationUp");
			break;
		case UIImageOrientationDown: // 180 deg rotation
			NSLog(@"UIImageOrientationDown");
			break;
		case UIImageOrientationLeft:// 90 deg CCW
			
			NSLog(@"UIImageOrientationLeft");
			
			break;
		case UIImageOrientationRight: // 90 deg CW
			NSLog(@"UIImageOrientationRight");
			break;
		case UIImageOrientationUpMirrored:// as above but image mirrored along
			// other axis. horizontal flip
			NSLog(@"UIImageOrientationUpMirrored");
			break;
		case UIImageOrientationDownMirrored:// horizontal flip
			NSLog(@"UIImageOrientationDownMirrored");
			break;
		case UIImageOrientationLeftMirrored: // vertical flip
			NSLog(@"UIImageOrientationLeftMirrored");
			break;
		case UIImageOrientationRightMirrored: // vertical flip
			NSLog(@"UIImageOrientationRightMirrored");
			break;
			
			
	}
	unsigned char* pSrc =[toolClass CGImageToRawdata:[image CGImage]];
	//iPhonePhotoFilterPastels(pSrc, image.size.width, image.size.height);
	iPhonePhotoFilterPastels(pSrc, image.size.width, image.size.height);
	CGDataProviderRef P1 = CGDataProviderCreateWithData(NULL, pSrc, (image.size.width)*(image.size.height)*4, NULL);
	
	
	UIImage* returnImg  = [[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																		 CGColorSpaceCreateDeviceRGB (),
																		 kCGBitmapByteOrderDefault,
																		 P1, 
																		 NULL,
																		 NO,
																		 kCGRenderingIntentDefault)]autorelease];
	
	CGDataProviderRelease(P1);
	free(pSrc);
	return returnImg;
	
}
+(UIImage*)imageFilter4:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoOldMovie(pSrc,image.size.width,image.size.height,50);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter5:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,40);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter6:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoGaussianFilter(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter7:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoGrayFilter1(pSrc,image.size.width,image.size.height,50);
	iPhonePhotoFilterLV03(pSrc,image.size.width,image.size.height);
	
	iPhonePhotoGaussianFilter5x5_x(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter8:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoMosaic(pSrc,image.size.width,image.size.height,50);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter9:(UIImage*)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter10:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}  
+(UIImage*)imageFilter11:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter12:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter13:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter14:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter15:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter16:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter17:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter18:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoFilterLV04(pSrc,image.size.width,image.size.height);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter19:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoLv09Filter(pSrc,image.size.width,image.size.height,50);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}



////끝까지 네온
+(UIImage*)imageFilter20:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,90);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter21:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,10);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter22:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,20);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter23:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,30);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter24:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,40);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter25:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,50);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter26:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,60);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter27:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,70);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter28:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,80);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}
+(UIImage*)imageFilter29:(UIImage *)image{
	unsigned char* pSrc=[toolClass CGImageToRawdata:[image CGImage]];
	iPhonePhotoNeon(pSrc,image.size.width,image.size.height,100);
	CGDataProviderRef P1=CGDataProviderCreateWithData(NULL,pSrc,(image.size.width)*(image.size.height)*4,NULL);
	
	UIImage* returnIMG=[[[UIImage alloc]initWithCGImage:CGImageCreate(image.size.width, image.size.height, 8, 32,image.size.width*4, 
																	  CGColorSpaceCreateDeviceRGB (),
																	  kCGBitmapByteOrderDefault,
																	  P1, 
																	  NULL,
																	  NO,
																	  kCGRenderingIntentDefault)]autorelease];
	CGDataProviderRelease(P1);
	free(pSrc);
	
	return returnIMG;
}

@end
